package com.suxin.plugin.intergration.application;

import com.suxin.plugin.intergration.IntegrationConfiguration;
import com.suxin.plugin.listener.PluginListener;
import com.suxin.plugin.listener.PluginListenerFactory;
import org.springframework.context.ApplicationContext;

import java.util.List;

/**
 * @author Tang
 * @classname AbstractPluginApplication
 * @description [  ]
 * @date 2022/6/26 18:36
 */
public abstract class AbstractPluginApplication implements PluginApplication {

    /**
     * 插件监听工厂
     */
    protected final PluginListenerFactory listenerFactory = new PluginListenerFactory();





    @Override
    public void addListener(PluginListener pluginListener) {
        listenerFactory.addListener(pluginListener);
    }

    @Override
    public <T extends PluginListener> void addListener(Class<T> pluginListener) {

    }

    @Override
    public void addListener(List<PluginListener> pluginListeners) {
        listenerFactory.addListeners(pluginListeners);
    }

    protected IntegrationConfiguration getConfiguration(ApplicationContext applicationContext) {
        IntegrationConfiguration configuration = null;
        configuration = applicationContext.getBean(IntegrationConfiguration.class);
        return configuration;
    }
}